import 'package:http/http.dart' as http;

class Http {
	String baseUrl;
	http.Client client;

	Http(String baseUrl) {
		this.baseUrl = baseUrl;
		this.client = new http.Client();
	}

	Future<http.Response> get(String api) {
		return this.client.get(this.generateApiUrl(api));
	}

	Future<http.Response> post(String api, body) {
		return this.client.post(this.generateApiUrl(api), body: body);
	}

	// 生成api url
//	@protected
	String generateApiUrl(String api) {
		return this.baseUrl + api;
	}

	// 生成带版本的url
	String generateApiUrlAndVersion(String api, String version) {
		return this.baseUrl + api + '/' + version;
	}
}